﻿// 读取列表
$(document).ready(function() {
    var salesmanid = LexunJS.GetQueryString("salesmanid");
    var salesman = LexunJS.GetQueryString("salesman");
    var deptid = LexunJS.GetQueryString("deptid");
    var deptName = LexunJS.GetQueryString("deptname");
    var startday = LexunJS.GetQueryString("startday");
    var endday = LexunJS.GetQueryString("endday");

    if (salesmanid > 0) {
        $("#utxtsub").val(salesmanid);
        $("#usubclass").val(salesman);
        $("#umainclass").val(deptName);
        $("#utxdeptid").val(deptid);
        $("#iStartDay").val(startday);
        $("#iEndDay").val(endday);

        //$("#spanTitle").html("<a href=\"DeptList.aspx?startday=" + escape(startday) + "&endday=" + endday + "\">部门总量</a> &gt; <a href=\"DeptUserList.aspx?deptid=" + deptid + "&deptname=" + escape(deptName) + "&startday=" + escape(startday) + "&endday=" + escape(endday) + "\">部门详情量(" + deptName + ")</a> &gt; 个人量化详情");
    }
    $("#spanTitle").html("个人量化详情");

    showList();

    // 业务员不允许查询其它人的量化信息
    if ($("#hIsManager").val() != 1) {
        $("#umainclass").attr("disabled", true);
        $("#usubclass").attr("disabled", true);
    }
});

function showList() {
    var deptid = $("#utxdeptid").val();             // 部门ID
    var userNoAndName = $("#utxtsub").val();        // 工号及名称
    var addDate1 = $("#iStartDay").val();           // 日期
    var addDate2 = $("#iEndDay").val();             // 日期
    var typeid = LexunJS.GetQueryString("typeid");  // typeid=2 部门按个人总量 3 个人按天量

    $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表 
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerReport.ashx',
        data: 'act=user_list&typeid=' + typeid + '&deptid=' + deptid + '&userNoAndName=' + escape(userNoAndName) + '&addDate1=' + escape(addDate1) + '&addDate2=' + escape(addDate2),
        timeout: '10000',
        error: function() {
            alert("系统繁忙,请稍候后试！");
        }, success: function(json) {
            showListCallBack(json);
        }
    });

    showReprot(1);
}

// 打开报表 1盘源更进 2客源跟进 3待看提醒 4已带看 5新添盘源 6新添客源 7独家 8反签 9钥匙 10查看电话 11上传图片盘源 12上传图片数 13自看房源
function showReprot(typeid) {
    var userNoAndName = $("#utxtsub").val();            // 工号及名称
    var addDate1 = $("#iStartDay").val();               // 日期
    var addDate2 = $("#iEndDay").val();                 // 日期
    var type = LexunJS.GetQueryString("typeid");        // type=2 部门按个人总量 3 个人按天量
    var ismanager = $("#hIsManager").val();             // 0置业或跑盘员 1管理者      

    if (type == 3 || ismanager == 0)
        document.getElementById("reportsDetail").src = "../Reports/ReportPages/UserList_Page.aspx?typeid=" + typeid + "&userNoAndName=" + userNoAndName + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    else
        document.getElementById("reportsDetail").src = "../Reports/ReportPages/DeptUserList_Page.aspx?typeid=" + typeid + "&deptid=0&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
}

/*
功能: 将返回的json数据进行排版
json: json数据        
*/
function showListCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) {
        $("#divList").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
        return;
    }

    var page = json.page;

    var ismanager = page.ismanager; // 0当前用户非查询部门管理者 1当前用户是查询部门管理者
    var station = page.station;     // 职称 0表示跑盘｜置业 1 表示管理者
    var addDate1 = $("#iStartDay").val();           // 日期
    var addDate2 = $("#iEndDay").val();             // 日期
    var typeid = LexunJS.GetQueryString("typeid");  // typeid=2 部门按个人总量 3 个人按天量

    var arr = [];
    arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    if (typeid == 3 || station == 0) {
        arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
        arr.push("时间");
        arr.push("</td>");
        arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
        arr.push("部门");
        arr.push("</td>");              
    }
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("人员");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(1)\" title=\"查看盘源跟进图形报表\" >盘源跟进</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(2)\" title=\"查看客源跟进图形报表\" >客源跟进</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(3)\" title=\"查看待看提醒图形报表\" >待看提醒</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(4)\" title=\"查看已带看售盘图形报表\" >已带看(售)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(16)\" title=\"查看已带看租盘图形报表\" >已带看(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(5)\" title=\"查看新添盘源图形报表\" >新增盘(售)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(14)\" title=\"查看新添盘源图形报表\" >新增盘(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(6)\" title=\"查看新添买客图形报表\" >新增客(买)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(15)\" title=\"查看新添租客图形报表\" >新增客(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(17)\" title=\"查看新转买客图形报表\" >新转客(买)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(18)\" title=\"查看新转租客图形报表\" >新转客(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(7)\" title=\"查看独家图形报表\" >独家</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(8)\" title=\"查看反签图形报表\" >反签</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(9)\" title=\"查看钥匙图形报表\" >钥匙</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(10)\" title=\"查看电话图形报表\" >查看电话</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(11)\" title=\"查看上传图片盘源图形报表\" >上传图片盘源</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(12)\" title=\"查看上传图片数图形报表\" >上传图片数</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(13)\" title=\"查看自看房源图形报表\" >自看房源</a>");
    arr.push("</td>");


    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(19)\" title=\"查看家访图形报表\" >家访</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(21)\" title=\"查看诚意金图形报表\" >诚意金</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(22)\" title=\"查看摆台图形报表\" >摆台</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(23)\" title=\"查看售后服务图形报表\" >售后服务</a>");
    arr.push("</td>");
    
    
    arr.push("</tr>");

    var total_hfollow = 0;
    var total_cfollow = 0;
    var total_look = 0;
    var total_looked = 0;
    var total_newhousing = 0;
    var total_newcustomer = 0;
    var total_only = 0;
    var total_versa = 0;
    var total_key = 0;
    var total_telphone = 0;
    var total_hasphoto = 0;
    var total_photo = 0;
    var total_self = 0;
    var total_mark1 = 0;    // 租盘
    var total_mark2 = 0;    // 租客
    var total_mark3 = 0;    // 已带看(租)
    var total_mark4 = 0;    // 新转客(买)
    var total_mark5 = 0;    // 新转客(租)

    //19 家访visit  21诚意金EarnestMoney  22摆台talks  23 售后服务afterservice

    var total_visit = 0;
    var total_EarnestMoney = 0;
    var total_talks = 0;
    var total_afterservice = 0;
    
    var addDate1 = $("#iStartDay").val();           // 日期
    var addDate2 = $("#iEndDay").val();             // 日期

    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        total_hfollow += parseInt(record[i].hfollow);
        total_cfollow += parseInt(record[i].cfollow);
        total_look += parseInt(record[i].look);
        total_looked += parseInt(record[i].looked);
        total_newhousing += parseInt(record[i].newhousing);
        total_newcustomer += parseInt(record[i].newcustomer);
        total_only += parseInt(record[i].only);
        total_versa += parseInt(record[i].versa);
        total_key += parseInt(record[i].key);
        total_telphone += parseInt(record[i].telphone);
        total_hasphoto += parseInt(record[i].hasphoto);
        total_photo += parseInt(record[i].photo);
        total_self += parseInt(record[i].self);
        total_mark1 += parseInt(record[i].mark1);
        total_mark2 += parseInt(record[i].mark2);
        total_mark3 += parseInt(record[i].mark3);
        total_mark4 += parseInt(record[i].mark4);
        total_mark5 += parseInt(record[i].mark5);
        total_visit += parseInt(record[i].visit);
        total_EarnestMoney += parseInt(record[i].earnestmoney);
        total_talks += parseInt(record[i].talks);
        total_afterservice += parseInt(record[i].afterservice);


        if (i % 2 == 0)
            arr.push("<tr id='tr_" + i + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + i + "')\" >");
        else
            arr.push("<tr id='tr_" + i + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + i + "')\" >");

        if (typeid == 3 || station == 0) {
            arr.push("<td height='20' class='STYLE6'>");
            arr.push("2012-10-26</td>");
            arr.push("<td height='20' class='STYLE6'>");
            arr.push("<a onclick=\"FKdeptCHECK()\">网管部</a></td>");

            addDate1 = record[i].countdate;
            addDate2 = record[i].countdate;
        }
        arr.push("<td height='20' class='STYLE6'>");
        if (typeid == 3 || station == 0) {
            if (ismanager == 1) {
                arr.push("<a onclick=\"FKalert(" + record[i].deptid + "," + record[i].salesmanid + ",'" + escape(addDate1) + "','" + escape(addDate2) + "','" + record[i].salesman + "')\">" + record[i].salesman + "</td>");
            }
            else {
                arr.push(record[i].salesman + "</td>");
            }
        } else {
            arr.push("<a href=\"javascript:goToDetail(0,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看该人的量化详情\" >" + record[i].salesman + "</a></td>");        
        }        

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].hfollow) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(1,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看盘源跟进详情\" >" + record[i].hfollow + "</a></td>");            
        else
            arr.push("" + record[i].hfollow + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].cfollow) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(2,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看客源跟进详情\" >" + record[i].cfollow + "</a></td>");                        
        else
            arr.push("" + record[i].cfollow + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].look) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(3,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看待看提醒详情\" >" + record[i].look + "</a></td>");                        
        else
            arr.push("" + record[i].look + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].looked) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(4,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看待看提醒详情\" >" + record[i].looked + "</a></td>");
        else
            arr.push("" + record[i].looked + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark3) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(16,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看已带看租盘详情\" >" + record[i].mark3 + "</a></td>");
        else
            arr.push("" + record[i].mark3 + "</td>");
            
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].newhousing) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(5,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添售盘详情\" >" + record[i].newhousing + "</a></td>");            
        else
            arr.push("" + record[i].newhousing + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark1) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(14,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添租盘详情\" >" + record[i].mark1 + "</a></td>"); 
        else
            arr.push("" + record[i].mark1 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].newcustomer) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(7,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添买客源详情\" >" + record[i].newcustomer + "</a></td>"); 
        else
            arr.push("" + record[i].newcustomer + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark2) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(15,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添租客源详情\" >" + record[i].mark2 + "</a></td>");
        else
            arr.push("" + record[i].mark2 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark4) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(17,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新转买客源详情\" >" + record[i].mark4 + "</a></td>");
        else
            arr.push("" + record[i].mark4 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark5) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(18,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新转租客源详情\" >" + record[i].mark5 + "</a></td>");
        else
            arr.push("" + record[i].mark5 + "</td>");
            
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].only) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(8,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看独家详情\" >" + record[i].only + "</a></td>"); 
        else
            arr.push("" + record[i].only + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].versa) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail('9','" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看反签详情\" >" + record[i].versa + "</a></td>"); 
        else
            arr.push("" + record[i].versa + "</td>");



        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].key) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(20,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看钥匙详情\" >" + record[i].key + "</a></td>");
        else
            arr.push("" + record[i].key + "</td>");
            
            
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].telphone) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(11,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看电话详情\" >" + record[i].telphone + "</a></td>"); 
        else
            arr.push("" + record[i].telphone + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].hasphoto + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].photo + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        //arr.push("" + record[i].self + "</td>");
        if (parseInt(record[i].self) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(12,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看自看房源详情\" >" + record[i].self + "</a></td>");
        else
            arr.push("" + record[i].self + "</td>");

        //19 家访visit  21诚意金EarnestMoney  22摆台talks  23 售后服务afterservice

        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].visit) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(21,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看家访房源详情\" >" + record[i].visit + "</a></td>");
        else
            arr.push("" + record[i].visit + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].earnestmoney) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(22,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看诚意金详情\" >" + record[i].earnestmoney + "</a></td>");
        else
            arr.push("" + record[i].earnestmoney + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].talks) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(23,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看摆台详情\" >" + record[i].talks + "</a></td>");
        else
            arr.push("" + record[i].talks + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].afterservice) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(24,'" + record[i].salesmanid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看售后服务详情\" >" + record[i].afterservice + "</a></td>");
        else
            arr.push("" + record[i].afterservice + "</td>");

        
            
    }
    // 底部总计
    arr.push("<tr bgcolor='#FFF6FF'>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>总计：</b>");
    arr.push("</td>");
    if (typeid == 3 || station == 0) {
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("</td>");
    }
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_hfollow + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_cfollow + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_look + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_looked + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark3 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_newhousing + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark1 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_newcustomer + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark2 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark4 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark5 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_only + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_versa + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_key + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_telphone + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_hasphoto + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_photo + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_self + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_visit + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_EarnestMoney + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_talks + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_afterservice + "</b>");
    arr.push("</td>");
    
    
    arr.push("</tr>");
    arr.push("</table>");

    $("#divList").html(arr.join('')); // 显示列表
}

// 选中某行
function selectedTr(id) {
    $("tr").removeClass("selected");
    $("#tr_" + id).addClass("selected");

    return false;
}

// 响应键盘查询
function responseEnter(e) {
    var key = window.event ? e.keyCode : e.which;
    if (key == 13)
        search();
}

// 查看详情
function goToDetail(typeid, salesmanid, addDate1, addDate2) {
    var title = "";
    var url = "";

    if (typeid == 0) {
        title = " 个人量化详情";
        url = "../AM/UserList.aspx?typeid=3&salesmanid=" + salesmanid + "&startday=" + escape(addDate1) + "&endday=" + escape(addDate2);
    }
    if (typeid == 1) {
        title = "盘源跟进信息";
        url = "../AM/HousingFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=1";
    }
    else if (typeid == 2) {
        title = "客源跟进信息";
        url = "../AM/CustomerFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 3) {
        title = "待看提醒";
        url = "../AM/CustomerAlertList.aspx?ftype=" + escape("约看") + "&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 4) {
        title = "带看房(售)";
        url = "../AM/CustomerFollowList.aspx?ftype=" + escape("带看售房") + "&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 16) {
        title = "带看房(租)";
        url = "../AM/CustomerFollowList.aspx?ftype=" + escape("带看租房") + "&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 5) {
        title = "新添售盘";
        url = "../AM/Housing_List.aspx?reporttypeid=1&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 14) {
        title = "新添租盘";
        url = "../AM/Housing_List.aspx?reporttypeid=4&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 7) {
        title = "新添买客";
        url = "../AM/Customer_List.aspx?reporttypeid=1&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 15) {
        title = "新添租客";
        url = "../AM/Customer_List.aspx?reporttypeid=2&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 17) {
        title = "新转买客";
        url = "../AM/Customer_List.aspx?reporttypeid=17&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 18) {
        title = "新转租客";
        url = "../AM/Customer_List.aspx?reporttypeid=18&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 8) {
        title = "独家";
        url = "../AM/Housing_List.aspx?reporttypeid=2&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 9) {
        title = "反签";
        url = "../AM/Housing_List.aspx?reporttypeid=3&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 11) {
        title = "查看电话";
        url = "../AM/TelList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 12) {
        title = "自看房";
        url = "../AM/HousingFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=2";
    }
    else if (typeid == 20) {
        title = "钥匙";
        url = "../AM/Housing_List.aspx?reporttypeid=20&salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 21) {
        title = "家访";
        url = "../AM/HousingFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=21";

    }else if(typeid ==22)
    {
        title = "诚意金";
        url = "../AM/CustomerFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype="+escape('诚意金');
    }
     else if(typeid ==23)
    {
        title = "摆台";
        url = "../AM/CustomerFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype="+escape('摆台');
    
    }else if(typeid ==24)
    {
        title = "售后服务";
        url = "../AM/CustomerFollowList.aspx?salesmanid=" + salesmanid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype="+escape('成交后服务');
    }
    
    
    self.parent.closeTab(title);
    self.parent.addTab(title, url, 'icon-nav');
}